#pragma once
#include "ConfigurationState.h"
#include "MetricMeasure.h"
#include "MillingMachine3C.h"
#include "MillingTool.h"
#include "PathsDrawElement.h"
#include "ErrorInfo.h"
#include "Point3D.h"
#include <vector>
using namespace std;

class SimApp
{
private:
	vector<ConfigurationState*>::iterator currentState;
	MY_DATATYPE x,y,z;
	ErrorInfo ** millingErrors;
	void parseInitMsg(const char * line,int lineNo);
	void parseInstruction(const char * line,int lineNo);
	void parseControlInstruction(const char * line,int lineNo);
	MetricMeasure* getMetricMeasure(const char * line);
	vector<ConfigurationState*> * states;
	MetricMeasure * measure;
	PathsDrawElement * pathDrawElement;
	void processStates(vector<ConfigurationState *> *& states,const Point3D & pathCenter,NotifyProgressCallback progressFuncNotify,ErrorNotifyCallback errorNotifyFunc);
	void transformPathPointToMachinePoint(double pathPointX,double pathPointY,double pathPointZ,MY_DATATYPE * machinePointX,MY_DATATYPE * machinePointY,MY_DATATYPE * machinePointZ);
	int getFileLineNumbers(const char * fName);
	int animStep;
public:
	MillingTool * tool;
	Point3D pathCenter;
	SimApp(UINT materialHeight,UINT materialWidth,UINT depth);
	~SimApp(void);
	void SetPathCenter(double x,double y,double z);
	int parseFile(const char * fName,NotifyProgressCallback progressFunc,ErrorNotifyCallback errorNotifyFunc);
	MillingMachine3C * machine;
	UINT GetMaterialSize();
	void ProcessStates(NotifyProgressCallback progressNotifyFunc,ErrorNotifyCallback errorNotifyFunc);
	bool PerformAnimationStep(NotifyProgressCallback progressFuncNotify,ErrorNotifyCallback errFuncNotify);
	void RewindAnitmation();
	void CreateMaterial(UINT materialWidth,UINT materialHeight,UINT initDepth);
	void CreateToroidalTool(double length,int diameter);
	void CreateBallTool(double length,int diameter);
	void SetToolX(double val);
	void SetToolY(double val);
	void SetToolZ(double val);
	double GetToolX();
	double GetToolY();
	double GetToolZ();
	PathsDrawElement* GetToolPathDrawElement();
	UINT getCurrentInstructionNumber();
};

